package com.luyuan.web.controller.gallery;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.luyuan.common.annotation.Log;
import com.luyuan.common.core.controller.BaseController;
import com.luyuan.common.core.domain.AjaxResult;
import com.luyuan.common.enums.BusinessType;
import com.luyuan.gallery.domain.ExhiGallery;
import com.luyuan.gallery.service.IExhiGalleryService;
import com.luyuan.gallery.vo.ExhiGalleryVO;
import com.luyuan.common.utils.poi.ExcelUtil;
import com.luyuan.common.core.page.TableDataInfo;

/**
 * 展厅Controller
 * 
 * @author luyuan
 * @date 2025-11-13
 */
@RestController
@RequestMapping("/gallery/gallery")
public class ExhiGalleryController extends BaseController {
    @Autowired
    private IExhiGalleryService exhiGalleryService;

    /**
     * 查询展厅列表
     */
    @PreAuthorize("@ss.hasPermi('gallery:gallery:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExhiGallery exhiGallery) {
        startPage();
        List<ExhiGalleryVO> list = exhiGalleryService.selectExhiGalleryList(exhiGallery);
        return getDataTable(list);
    }

    /**
     * 导出展厅列表
     */
    @PreAuthorize("@ss.hasPermi('gallery:gallery:export')")
    @Log(title = "展厅", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExhiGallery exhiGallery) {
        List<ExhiGalleryVO> list = exhiGalleryService.selectExhiGalleryList(exhiGallery);
        ExcelUtil<ExhiGalleryVO> util = new ExcelUtil<ExhiGalleryVO>(ExhiGalleryVO.class);
        util.exportExcel(response, list, "展厅数据");
    }

    /**
     * 获取展厅详细信息
     */
    @PreAuthorize("@ss.hasPermi('gallery:gallery:query')")
    @GetMapping(value = "/{galleryId}")
    public AjaxResult getInfo(@PathVariable("galleryId") Long galleryId) {
        return success(exhiGalleryService.selectExhiGalleryByGalleryId(galleryId));
    }

    /**
     * 新增展厅
     */
    @PreAuthorize("@ss.hasPermi('gallery:gallery:add')")
    @Log(title = "展厅", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExhiGallery exhiGallery) {
        return toAjax(exhiGalleryService.insertExhiGallery(exhiGallery));
    }

    /**
     * 修改展厅
     */
    @PreAuthorize("@ss.hasPermi('gallery:gallery:edit')")
    @Log(title = "展厅", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExhiGallery exhiGallery) {
        return toAjax(exhiGalleryService.updateExhiGallery(exhiGallery));
    }

    /**
     * 删除展厅
     */
    @PreAuthorize("@ss.hasPermi('gallery:gallery:remove')")
    @Log(title = "展厅", businessType = BusinessType.DELETE)
    @DeleteMapping("/{galleryIds}")
    public AjaxResult remove(@PathVariable Long[] galleryIds) {
        return toAjax(exhiGalleryService.deleteExhiGalleryByGalleryIds(galleryIds));
    }
}
